package com.winning.pregnancyandroid.activities;

import com.example.pregnancyandroid.R;

import android.os.Bundle;
import android.os.StrictMode;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MotionEvent;
import android.view.Window;
import android.widget.GridView;

public class MainActivity extends Activity {
	private GestureDetector gdetector = null;
	
	
	@SuppressLint("NewApi")  //一定要加这个，不然就老实的去写线程访问吧
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()       
        .detectDiskReads()       
        .detectDiskWrites()       
        .detectNetwork()   // or .detectAll() for all detectable problems       
        .penaltyLog()       
        .build());       
		StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()       
        .detectLeakedSqlLiteObjects()    
        .penaltyLog()       
        .penaltyDeath()       
        .build());  
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);// 去掉标题栏
		setContentView(R.layout.activity_main);
		gdetector = new GestureDetector(MainActivity.this, new MyGestureListener());
		findViews(); //初始化样式
		
	
		
		initData();//初始化数据

		setListener();
		
	}
	public boolean onCreateOptionsMenu(Menu menu) {
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.actionbar, menu);
		return true;
		
	};
	
	public boolean onTouchEvent(MotionEvent event){
		return gdetector.onTouchEvent(event);
		
	}
	public  void findViews(){
	}
	
	public void initData(){
		
	}
	
	
	private void setListener(){

	}
	class MyGestureListener extends SimpleOnGestureListener{
		@Override
		public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
				float velocityY) {
			float y = e1.getY() - e2.getY();
			if(y > 10){
				Intent it = new Intent(MainActivity.this, ModesActivity.class);
				startActivity(it);
			}
			// TODO Auto-generated method stub
			return super.onFling(e1, e2, velocityX, velocityY);
		}
	}
}
